package com.wgc.goods.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wgc.goods.domain.Classify;
import com.wgc.goods.mapper.ClassifyMapper;
import com.wgc.goods.service.ClassifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 15776
 * @description 针对表【goods_spec(规格表)】的数据库操作Service实现
 * @createDate 2024-07-27 11:24:17
 */
@Service
public class ClassifyServiceImpl extends ServiceImpl<ClassifyMapper, Classify>
        implements ClassifyService {
@Autowired
    private ClassifyMapper ClassifyMapper;

    @Override
    public List<Classify> selectAll() {
        LambdaQueryWrapper <Classify> lqw = new LambdaQueryWrapper<>();
        lqw.eq(Classify::getIsDelete,0);
        return ClassifyMapper.selectList(lqw);

    }

    @Override
    public Integer insert(Classify iClassify) {
        return ClassifyMapper.insert(iClassify);
    }

    @Override
    public Integer update(Classify classify) {
        return ClassifyMapper.updateById(classify);
    }

    @Override
    public Integer delete(String ids) {
        try {
            String[] split = ids.split(",");
            for (String id : split) {
                Classify iClassify = new Classify();
                iClassify.setId(Long.parseLong(id));
                iClassify.setIsDelete(1);
                ClassifyMapper.updateById(iClassify);
            }
            return 1;
        }catch (Exception e){
            return -1;
        }
    }


}




